﻿CREATE PROCEDURE [dbo].[ListCategoriesByProject]
@ProjectID INT
AS
SELECT	c.CategoryID,
		c.Name,     
        c.Abbreviation AS CategoryShortName,
        c.EstDuration,
        ISNULL(Sum(e.Duration), 0) AS ActualHours,
        c.ProjectID
        
FROM vwProjectCategory c 
		LEFT OUTER JOIN EntryLog e ON c.CategoryID = e.CategoryID AND c.ProjectID = e.ProjectID
		
WHERE	c.ProjectID = @ProjectID

GROUP BY c.CategoryID, 
		c.Name, 
		c.Abbreviation, 
		c.EstDuration,
        c.ProjectID

